﻿@model ValueTuple<ItemModel, DataField>
@using NewLife;
@using NewLife.Cube
@using XCode;
@using XCode.Configuration;
@{
    var item1 = Model.Item1;
    var item2 = Model.Item2;
    var name = item1.Name;
	var value = item1.Value;
	var type = item1.Type;
	var length = item1.Length;
    var display = item2?.DisplayName;

	var atts = HtmlHelper.AnonymousObjectToHtmlAttributes(item1.HtmlAttributes);
	if (!atts.ContainsKey("class")) atts.Add("class", "layui-input");
    if (!atts.ContainsKey("placeholder")) atts.Add("placeholder", "请输入"+display);
    if (!atts.ContainsKey("lay_verify")&&!item2.Nullable&&!item2.Name.EqualIgnoreCase("CreateUserID", "CreateUser", "CreateTime", "CreateIP",
                "UpdateUserID", "UpdateUser", "UpdateTime", "UpdateIP", "StateCode", "StatusCode","Auditor","AuditTime","EffectiveTime","DeactivateTime","BomDetailedIDs")) atts.Add("lay-verify", "required");
}
@if (name.EqualIgnoreCase("Pass", "Password"))
{
	if (!atts.ContainsKey("autocomplete")) atts.Add("autocomplete", "off");
	@Html.Password(name, value, atts)
}
else if (name.EqualIgnoreCase("Phone", "TelPhone", "OfficePhone", "HomePhone", "Fax"))
{
	if (!atts.ContainsKey("type")) atts.Add("type", "tel");
		@Html.TextBox(name, value, atts)
}
else if (name.EqualIgnoreCase("Mobile", "MobilePhone", "CellularPhone"))
{
	if (!atts.ContainsKey("type")) atts.Add("type", "tel");
		@Html.TextBox(name, value, atts)
}
else if (name.EqualIgnoreCase("email", "mail"))
{
	if (!atts.ContainsKey("type")) atts.Add("type", "email");
		@Html.TextBox(name, value, atts)
}
else if (name.EndsWithIgnoreCase("url"))
{
	//if (!atts.ContainsKey("type")) atts.Add("type", "url");
    @Html.TextBox(name, value, atts)
}
else if (length < 0 || length >= 300 || (length >= 200 && name.EqualIgnoreCase("Remark", "Description", "Comment")))
{
    if (atts.ContainsKey("class")) atts.Remove("class");
    atts.Add("class", "layui-textarea");
	@Html.TextArea(name, (String)value, 3, 20, atts)
}
else
{
	@Html.TextBox(name, value, atts)
}